package com.ityueqiangu.project.galleryappoint.service.impl;

import com.ityueqiangu.core.enums.SysFlagStatusEnum;
import com.ityueqiangu.core.util.PrimaryKeyUtils;
import com.ityueqiangu.core.util.ServletUtils;
import com.ityueqiangu.core.util.UserUtil;
import com.ityueqiangu.project.galleryappoint.domain.GalleryAppoint;
import com.ityueqiangu.project.galleryappoint.mapper.GalleryAppointMapper;
import com.ityueqiangu.project.galleryappoint.service.IGalleryAppointService;
import com.ityueqiangu.core.util.StringUtils;
import com.ityueqiangu.core.enums.CommonEnum;
import com.ityueqiangu.core.web.result.ResultDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author Clever、xia
 * @title: GalleryAppointServiceImpl
 * @description:
 * @date 2021-03-18 14:50:34
 */
@Service
public class GalleryAppointServiceImpl implements IGalleryAppointService{

    @Autowired
    private GalleryAppointMapper galleryAppointMapper;

    /**
     * 查询分页记录
     *
     * @return 返回集合，没有返回空List
     */
     public List<GalleryAppoint> selectGalleryAppointList(GalleryAppoint galleryAppoint) {
       return galleryAppointMapper.selectGalleryAppointList(galleryAppoint);
    }


    /**
     * 根据主键查询
     *
     * @param id 主键
     * @return 返回ResultInfo
     */
    public GalleryAppoint selectGalleryAppointById(Integer id) {
    	return galleryAppointMapper.selectGalleryAppointById(id);
    }
	
    /**
     * 新增
     *
     * @param galleryAppoint 新增的记录
     * @return 返回ResultInfo
     */
    public Integer insertGalleryAppoint(GalleryAppoint galleryAppoint) {
    	return galleryAppointMapper.insertGalleryAppoint(galleryAppoint);
    }
	
	
    /**
     * 修改
     *
     * @param galleryAppoint 修改的记录
     * @return 返回
     */
    public Integer updateGalleryAppoint(GalleryAppoint galleryAppoint) {
    	return galleryAppointMapper.updateGalleryAppoint(galleryAppoint);
    }
	
  
    /**
     * 删除记录
     *
     * @param id 主键
     * @return 返回
     */
    public Integer deleteGalleryAppointById(Integer id) {
    	return galleryAppointMapper.deleteGalleryAppointById(id);
    }

    /**
     * 审批
     * @param galleryAppoint
     * @return
     */
    public Integer approve(GalleryAppoint galleryAppoint){
        //生成 预约号
        galleryAppoint.setAppointNo(PrimaryKeyUtils.generateOrderNo());
        galleryAppoint.setApproveUserId(UserUtil.getCurrentUser(ServletUtils.getRequest()).getId());
        galleryAppoint.setApproveUserName(UserUtil.getCurrentUser(ServletUtils.getRequest()).getLoginName());
        galleryAppoint.setApproveTime(new Date());
        galleryAppoint.setIsApprove(SysFlagStatusEnum.ONE.getKey());
        return galleryAppointMapper.updateGalleryAppoint(galleryAppoint);
    }
	
}